#version 460
#extension GL_GOOGLE_include_directive : enable
#extension GL_EXT_scalar_block_layout : enable
#extension GL_EXT_shader_explicit_arithmetic_types_int64 : require

#include "../../../core/shader_binding_ID.h"
#include "../../../core/shader_taster_transform.h"
#include "../../../core/shader_taster_color.h"

#include "../../../core/shader_mesh.h"
#include "../../../core/shader_meshTranformProp.h"



layout(points, invocations = 3) in;
layout(line_strip, max_vertices = 6) out;



layout(push_constant, scalar) uniform _push_constants {
	S_ShaderConst_TextAttr drawProp;
};

layout(location = 0) in uint vCol[];
layout(location = 1) in uint vInstance[];
//layout(location = 2) in uint vVertIndex[];

in gl_PerVertex {
	vec4  gl_Position;
	float gl_PointSize;
}gl_in[];


layout(location = 1) out GS_FS_VERTEX {
	vec4	vColor;
};

//vec3 q_vert[4] = {vec3(0,0,0), vec3(0,1,0), vec3(1,1,0), vec3(1,0,0)};

void main(void) {
	mat4 modelMat = mat_Model[drawProp.MatrixOffset + vInstance[0]];
	
	R_GlobalParameter_TranformProp meshTranformProp = R_GlobalParameter_TranformProp(drawProp.m_Address_MeshPropOffset);
	S_MeshTranformProp prop = meshTranformProp.TranformPropPtr[0];

	R_GlobalParameter_iVec4 ivec4_GParam = R_GlobalParameter_iVec4(drawProp.m_Address_TextCoord);
	R_GlobalParameter_UI32 ui32_GParam = R_GlobalParameter_UI32(drawProp.m_Address_TextID);
	R_GlobalParameter_UVec2 uvec2_GParam = R_GlobalParameter_UVec2(drawProp.m_Address_TextID_Range);

	

	uvec2 textID_range = uvec2_GParam.uvec2Ptr[gl_PrimitiveIDIn];

	vec4 rootCoord = gl_in[0].gl_Position;
	vec4 panelCoord = rootCoord;
	
	rootCoord = mat_ProjecView[0] * mat_Model[drawProp.MatrixOffset + vInstance[0]] * rootCoord;
	panelCoord = rootCoord;
	panelCoord.x += drawProp.m_CoordOffset.x;
	panelCoord.y -= drawProp.m_CoordOffset.y;

	//float proj = rootCoord.w;
	gl_Position = rootCoord;
	gl_PointSize = 1;
	vColor = vec4(1, 0.4, 0.4, 1);
	
	vec3(1, 0.4, 0.4);
	EmitVertex();
	

	gl_Position = panelCoord;
	gl_PointSize = 1;
	//vColor = vec4(1,0.5,0,1);
	vColor = vec4(0.5, 0.2, 0.2, 1);
	EmitVertex();

	EndPrimitive();
}







